package com.haojiangbo.hander;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.fengfei.lanproxy.protocol.Constants;
/**
 * 处理反向代理之间的数据
 */
public class PostManHander extends ChannelInboundHandlerAdapter {


    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf byteBuf = (ByteBuf) msg;
        //System.err.println("postMan = = 回显数据"+ MyByteBufUtils.byteBuf2String(byteBuf));
        Channel targetChange =   ctx.channel().attr(Constants.NEXT_CHANNEL).get();
        //System.err.println("postMan = = 连接状态"+ targetChange.isActive() );
        if(null != targetChange){
            targetChange.writeAndFlush(byteBuf);
        }
    }
}
